namespace SimpleWebServices.Configuration
{
    using System.Xml.XPath;
    using Xunit;

    public sealed class MaintenanceSettingsFacts
    {
        [Fact]
        public void typedef()
        {
            Assert.True(new ObjectExpectations<MaintenanceSettings>()
                .DerivesFrom<object>()
                .IsConcreteClass()
                .IsSealed()
                .HasDefaultConstructor()
                .XmlRoot("maintenance")
                .Result);
        }

        [Fact]
        public void deserialize()
        {
            MaintenanceSettings actual = "<maintenance enabled='true' />".Deserialize<MaintenanceSettings>();

            Assert.True(actual.Enabled);
        }

        [Fact]
        public void deserializeEmpty()
        {
            MaintenanceSettings actual = "<maintenance />".Deserialize<MaintenanceSettings>();

            Assert.False(actual.Enabled);
        }

        [Fact]
        public void serialize()
        {
            MaintenanceSettings obj = new MaintenanceSettings
            {
                Enabled = true
            };

            XPathNavigator navigator = obj.Serialize().CreateNavigator();

            Assert.True((bool)navigator.Evaluate("1=count(/maintenance[@enabled='true'])"));
        }

        [Fact]
        public void ctor()
        {
            Assert.NotNull(new MaintenanceSettings());
        }

        [Fact]
        public void prop_Enabled()
        {
            Assert.True(new PropertyExpectations(typeof(MaintenanceSettings).GetProperty("Enabled"))
                .XmlAttribute("enabled")
                .IsAutoProperty<bool>()
                .Result);
        }
    }
}